
function [sG dir] = suppression_4_inputs(G, H, V,D1,D2)
% SUPPRESSION_4_INPUTS
% 
% description: 
% Iterate trough all image pixels (excluding 1 pixel border conditions in
% pixels which don't have all of neighbours) in order to suppress pixels 
% which are not part of edges, pixels, directions are decided depending on 
% the corresponding four values of that pixel in the details passed maximum
% value of details will win the direction (max=ver =>vertical edge)
%
% Input:
%     G, H, V,D1,D2  vertical, horizontal, diagonalx2 details after
%
% Output: 
%         sG:non maxima suppressed image magnitude
%         dir:edge direction of each pixel in sG
%
% Example : 
%        [sG dir] = suppression_4_inputs(G, H, V,D1,D2)
% 
% Created on:    2014-01-04 (Mohamed Marouf)
% Last revision: 2014-01-23 (Mohamed Marouf) 
% Notice:
% -This function should be later combined with suppression_3_inputs
% -method parameter should be passed too. 

 height = size(G, 1);
 width = size(G,2);

 dir = zeros(height,width);
 sG = zeros(height, width);   
 
 for y = 2 : height - 1
   for x = 2 : width - 1
     pH = H(y,x);
     pV = V(y,x);        
     pD1= D1(y,x);  
     pD2=D2(y,x); 
     [~,indx]=max([pH,pV,pD1,pD2]);
     switch indx
         case 2
          edge_max = max([G(y, x-1), G(y,x), G(y, x+1)]); %vertical edge
          dir(y,x)=4;
         case 1
          edge_max = max([G(y-1, x), G(y,x), G(y+1, x)]); %horizontal edge
          dir(y,x)=3;
         case 3
          edge_max = max([G(y+1, x+1), G(y,x), G(y-1, x-1)]); %diagonal +45 degrees
          dir(y,x)=2; 
         case 4
          edge_max = max([G(y-1, x+1), G(y,x), G(y+1, x-1)]); %diagonal -45 degrees
          dir(y,x)=1; 
     end
     if (G(y, x) == edge_max)
        sG(y, x) = edge_max;
     end    
   end
 end

    


